package com.asiainfo.ncrm.util;

import java.util.Set;

import com.asiainfo.ncrm.ant.AntApplication;

import android.app.Activity;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * TODO SharedPreferences工具类
 * 
 * @author 王剑洪
 * @date 2016年3月27日
 */
public class SharedUtil {
	public static String PREF_NAME = "con.ycss.ant.pref";

	static SharedPreferences getShared() {
		return AntApplication.getInstance().getSharedPreferences(PREF_NAME, 0);
	}

	public static void putBoolean(String key, boolean value) {
		Editor editor = getShared().edit();
		editor.putBoolean(key, value);
		editor.commit();
	}

	public static boolean getBoolean(String key, boolean defValue) {
		return getShared().getBoolean(key, defValue);
	}

	public static void putFloat(String key, float value) {
		Editor editor = getShared().edit();
		editor.putFloat(key, value);
		editor.commit();
	}

	public static float getFloat(String key, float defValue) {
		return getShared().getFloat(key, defValue);
	}

	public static void putInt(String key, int value) {
		Editor editor = getShared().edit();
		editor.putInt(key, value);
		editor.commit();
	}

	public static int getInt(String key, int defValue) {
		return getShared().getInt(key, defValue);
	}

	public static void putLong(String key, long value) {
		Editor editor = getShared().edit();
		editor.putLong(key, value);
		editor.commit();
	}

	public static long getLong(String key, long defValue) {
		return getShared().getLong(key, defValue);
	}

	public static void putString(String key, String value) {
		Editor editor = getShared().edit();
		editor.putString(key, value);
		editor.commit();
	}

	public static String getString(String key, String defValue) {
		return getShared().getString(key, defValue);
	}
//
//	public static void putStringSet(String key, Set<String> set) {
//		Editor editor = getShared().edit();
//		editor.putStringSet(key, set);
//		editor.commit();
//	}
//
//	public static Set<String> getStringSet(String key, Set<String> defValue) {
//		return getShared().getStringSet(key, defValue);
//	}

	public static void Logout() {
		Editor editor = getShared().edit();
		editor.clear().commit();
	}

}
